package cn.stylefeng.guns.modular.business.frequency.cmprovince.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import cn.stylefeng.guns.modular.business.frequency.cmprovince.service.CmProvinceService;
import cn.stylefeng.guns.modular.business.frequency.cmprovince.model.param.CmProvinceParam;

import javax.annotation.Resource;

/**
 * cm_province 控制器
 *
 * @author: yujie
 * @date: 2023/05/09 17:17
 */
@RestController
public class CmProvinceController {

    @Resource
    private CmProvinceService cmProvinceService;

    /**
     * 分页查询cm_province
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmProvince/page")
    @BusinessLog(title = "cm_province_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(CmProvinceParam cmProvinceParam) {
        return new SuccessResponseData(cmProvinceService.page(cmProvinceParam));
    }

    /**
     * 获取全部cm_province
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmProvince/list")
    @BusinessLog(title = "cm_province_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(CmProvinceParam cmProvinceParam) {
        return new SuccessResponseData(cmProvinceService.list(cmProvinceParam));
    }

    /**
     * 查看详情cm_province
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @GetMapping("/cmProvince/detail")
    @BusinessLog(title = "cm_province_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(CmProvinceParam.detail.class) CmProvinceParam cmProvinceParam) {
        return new SuccessResponseData(cmProvinceService.detail(cmProvinceParam));
    }

    /**
     * 添加cm_province
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmProvince/add")
    @BusinessLog(title = "cm_province_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(CmProvinceParam.add.class) CmProvinceParam cmProvinceParam) {
        cmProvinceService.add(cmProvinceParam);
        return new SuccessResponseData();
    }

    /**
     * 删除cm_province
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmProvince/delete")
    @BusinessLog(title = "cm_province_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(CmProvinceParam.delete.class) CmProvinceParam cmProvinceParam) {
        cmProvinceService.delete(cmProvinceParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑cm_province
     *
     * @author yujie
     * @date 2023/05/09 17:17
     */
    @PostMapping("/cmProvince/edit")
    @BusinessLog(title = "cm_province_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(CmProvinceParam.edit.class) CmProvinceParam cmProvinceParam) {
        cmProvinceService.edit(cmProvinceParam);
        return new SuccessResponseData();
    }


}
